<?php 
require("phpmailer/class.phpmailer.php");
include_once "constants.inc.php";

class MailBase {
	private $_mail;
	public function __construct() {
	$this->_mail = new PHPMailer(); 
	$this->_mail->IsSMTP(); // send via SMTP
	$this->_mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
	$this->_mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
	$this->_mail->Port = 465;
	$this->_mail->SMTPAuth = true; // turn on SMTP authentication
	$this->_mail->Username = GUSER; // SMTP username
	$this->_mail->Password = GPWD; // SMTP password
	}
	
	public function sendMail($email, $username, $subject, $body) {
	$webmaster_email = "admin@comicblocks.com"; //Reply to this email ID
	$this->_mail->From = $webmaster_email;
	$this->_mail->FromName = "Webmaster";
	$this->_mail->AddAddress($email,$username);
	$this->_mail->AddReplyTo($webmaster_email,"Webmaster");
	$this->_mail->WordWrap = 50; // set word wrap
	$this->_mail->IsHTML(true); // send as HTML
	$this->_mail->Subject = $subject;
	$this->_mail->Body = $body; //HTML Body

	if(!$this->_mail->Send())
	{
	echo "Mailer Error: " . $mail->ErrorInfo;
	}
	else
	{
	echo "Message has been sent";
	}
	}

}
?>